﻿//***************************************************
//
//       File Name:    FeiXiangLieChe.cs
//
//       Author:   王文军    Email:  546527816@qq.com
//
//
//***************************************************

using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class FeiXiangLieChe : MonoBehaviour {

    private Vector3 myLocalPostion;
    private Vector3 myLocalScale;
    private Quaternion myRotation;
    private Transform luoQuanJiangOne;
    private Transform luoQuanJiangTwo;

    private Camera uiCamera;
    public VehicleInfo vehicleInfo;
    private Transform cheShen;

    //各种组件是否显示
    private bool isNewAppearanceShow = true;
    private bool isNewPowerShow = true;
    private bool isNewMaterialShow = true;
    private bool isNewEngineShow = true;
    private bool isNewDirectionShow = true;
    private bool isRotate = true;
    private bool isZoom = false;
    public bool IsZoom
    {
        set { isZoom = value; }
    }
    public bool IsNewAppearanceShow
    {
        set { isNewAppearanceShow = value; }
    }
    public bool IsNewPowerShow
    {
        set { isNewPowerShow = value; }
    }
    public bool IsNewMaterialShow
    {
        set { isNewMaterialShow = value; }
    }
    public bool IsNewEngineShow
    {
        set { isNewEngineShow = value; }
    }
    public bool IsNewDirectionShow
    {
        set { isNewDirectionShow = value; }
    }
    public bool IsRotate
    {
        set { isRotate = value; }
    }

    void Awake()
    {
        cheShen = transform.Find("feixianglieche1");
        myLocalScale = cheShen.transform.localScale;
        myLocalPostion = cheShen.transform.localPosition;
        myRotation = cheShen.transform.localRotation;
        uiCamera = GameObject.FindGameObjectWithTag("UICamera").GetComponent<Camera>();
        luoQuanJiangOne = transform.Find("feixianglieche1/LuoQuanJiang1");
        luoQuanJiangTwo = transform.Find("feixianglieche1/LuoQuanJiang2");
    }

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (isRotate)
            cheShen.Rotate(Vector3.up, 15 * Time.deltaTime);
        luoQuanJiangOne.Rotate(Vector3.forward, 20 );
        luoQuanJiangTwo.Rotate(Vector3.forward, 20);
        if (!isZoom) return;
        TouchMoudel.TouchManager(uiCamera, cheShen, myLocalScale, vehicleInfo);
    }

    /// <summary>
    /// 复位
    /// </summary>
    public void ResetCheShen()
    {
        TouchMoudel.distance = 0;
        TouchMoudel.lastDist = 0;
        TouchMoudel.curDist = 0;
        cheShen.rotation = myRotation;
        cheShen.localPosition = myLocalPostion;
        cheShen.localScale = myLocalScale;
    }

    public void SetCheLunShow()
    {

    }
}
